package com.example.opencvdemo

import android.os.Bundle
import android.util.Log
import android.widget.Toast
import android.widget.Toast.LENGTH_LONG
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.ui.Modifier
import com.example.opencvdemo.ui.theme.OpenCVDemoTheme
import org.opencv.android.OpenCVLoader

class MainActivity : ComponentActivity() {
    private val TAG = "MainActivity"
    private val vm = MyViewModel()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        if (OpenCVLoader.initLocal()) {
            Log.i(TAG, "OpenCV loaded successfully");
        } else {
            Log.e(TAG, "OpenCV initialization failed!");
            (Toast.makeText(this, "OpenCV initialization failed!", LENGTH_LONG)).show();
            return;
        }
        setContent {
            OpenCVDemoTheme {
                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
//                    XorMatCompose(modifier = Modifier.padding(innerPadding))
//                    CvtColorCompose(modifier = Modifier.padding(innerPadding))
//                    ThresholdCompose(modifier = Modifier.padding(innerPadding))
//                    CutCompose(modifier = Modifier.padding(innerPadding))
                    HomeworkCompose(modifier = Modifier.padding(innerPadding), vm)

                }
            }
        }

    }
}
